package com.zany.tree.action;

import java.util.List;


import com.zany.tree.service.TreeService;
import com.zany.tree.vo.OrgInfoVO;
import com.opensymphony.xwork2.ActionSupport;

public class TreeAction extends ActionSupport {

	private static final long serialVersionUID = 7195266842418172990L;
	private TreeService treeService;
	private String javasrciptStr = "[";
	private String userCode ;
	public String execute() {
		List<OrgInfoVO> orgInfos = treeService.getAllTreeNode();
		for (int i = 0; i < orgInfos.size(); i++) {
			OrgInfoVO orgInfo = orgInfos.get(i);
			if(i!=0)javasrciptStr+=",";
			//点击叶节点把选中的节点带入父页面
				javasrciptStr += "\""+orgInfo.getOrgCode() + "|"
							  + orgInfo.getParentOrg() + "|" + orgInfo.getOrgName()
							  + "|javascript:setParentPage(\\'"+orgInfo.getOrgCode()
							  + "\\',\\'"+orgInfo.getOrgName()+"\\')\"";
		}
		javasrciptStr+="]";
		return SUCCESS;
	}

	public TreeService getTreeService() {
		return treeService;
	}

	public void setTreeService(TreeService treeService) {
		this.treeService = treeService;
	}

	public String getJavasrciptStr() {
		return javasrciptStr;
	}

	public void setJavasrciptStr(String javasrciptStr) {
		this.javasrciptStr = javasrciptStr;
	}

	public String getUserCode() {
		return userCode;
	}

	public void setUserCode(String userCode) {
		this.userCode = userCode;
	}
}
